const { JSDOM } = require("jsdom");

const Exchange = ({ res, proxyRes, response }) => {
  proxyRes.headers.location = "http://localhost:3000/chdstore/Shop/Cart";
  const location = proxyRes.headers.location;
  proxyRes.statusCode = 200;
  console.log(location, proxyRes.statusCode, "location");
  res.status(200);
  res.setHeader("Content-Type", "application/json");
  try {
    const dom = new JSDOM(response);
    const document = dom.window.document;
    console.log("document", response);
    return JSON.stringify({
      success: true,
    });
  } catch (error) {
    return JSON.stringify({
      success: false,
    });
  }
};

module.exports = {
  Exchange,
};
